<template>
  <!-- 新增仓库 -->
  <div class="stock">
    <div class="dropdown">
      <el-button type="primary" size="mini" @click.native="subMarker">{{ $t('btn.save') }}</el-button>
    </div>
    <el-tabs v-model="activeName">
      <el-tab-pane :label="$t('market.info')" name="first">
        <el-form ref="purchaseRef" :model="prodValue" label-width="100px">
          <el-form-item :label="$t('shop.fnumber')" prop="fbillno">
            <el-input v-model.trim="prodValue.fbillno" size="mini" />
          </el-form-item>
          <el-form-item :label="$t('market.direction')" prop="fdirection">
            <el-select v-model.trim="prodValue.fdirection" size="mini" filterable>
              <el-option label="现金流入/增加" :value="1" />
              <el-option label="现金流出/减少" :value="2" />
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('market.properType')" prop="fbilltypeid">
            <el-select v-model.trim="prodValue.fbilltypeid" size="mini" filterable>
              <el-option label="主表项目" :value="1" />
              <el-option label="附表项目" :value="2" />
            </el-select>
          </el-form-item>
          <el-form-item :label="$t('shop.name1')" style="width: 33.2%">
            <el-input v-model.trim="prodValue.fname" size="mini" style="height: 35px" />
          </el-form-item>
          <el-form-item :label="$t('market.descrip')" style="width: 33.2%">
            <el-input v-model.trim="prodValue.fdescription" size="mini" style="height: 35px" />
          </el-form-item>
        </el-form>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import {
  insertCashFlowProject
} from '@/api/basicManagement/cashFlow'

export default {
  data() {
    return {
      activeName: 'first',
      billtypes: [], // 类型
      prodValue: {
        fbillno: '',
        fdirection: 1,
        fbilltypeid: 1,
        fname: '',
        fdescription: ''
      }
    }
  },
  methods: {
    // 保存
    subMarker() {
      const DATA = {
        ...this.prodValue
      }
      insertCashFlowProject(DATA).then(res => {
        if (res.code === 0) {
          // 关闭当前页面
          this.$store.dispatch('tagsView/guanbi', this.$route)
          this.$router.push({ path: `/cashFlowDetail/${res.data.fid}` })
          this.$message({ showClose: true, message: res.message, type: 'success' })
        } else {
          this.$confirm(res.message, '提示', {
            confirmButtonText: '确定',
            type: 'warning'
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.stock {
  padding: 10px;
  background: #fff;
  min-height: calc(100vh - 100px);
  .el-input::v-deep .el-input__inner {
    height: 30px;
    line-height: 30px;
  }
  .el-form {
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;

    .el-form-item {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      height: 35px;
      width: 350px;
      margin-bottom: 5px;
      .btnType {
        margin-right: 20px;
      }

      .el-date-editor.el-input {
        width: 100% !important;
      }

      .el-select {
        width: 100%;
      }
    }
  }
}
</style>
